<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>添加代理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="{$Think.const.RESOURCE}img/favicon.ico">
    <link href="{$Think.const.RESOURCE}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.const.RESOURCE}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.const.RESOURCE}css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="{$Think.const.RESOURCE}css/animate.css" rel="stylesheet">
    <link href="{$Think.const.RESOURCE}css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="{$Think.const.RESOURCE}css/font.css">
    <link rel="stylesheet" href="{$Think.const.RESOURCE}css/xadmin.css">
    <script type="text/javascript" src="{$Think.const.RESOURCE}js/jquery.min.js"></script>
    <script type="text/javascript" src="{$Think.const.RESOURCE}lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="{$Think.const.RESOURCE}js/xadmin.js"></script>
    <script type="text/javascript" src="{$Think.const.RESOURCE}js/bootstrap-paginator.js"></script>
    <style>
      .layui-table td, .layui-table th {
          position: relative;
          padding: 9px 11px;
          min-height: 20px;
          line-height: 20px;
          font-size: 14px;
      }
    </style>

  </head>
  
  <body class="layui-anim layui-anim-fadein">
    <!-- <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页/添加代理</a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:39px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="{:U('member/agent')}" METHOD="POST">
          <input type="number" name="gameid"  placeholder="输入id,搜索代理人" value=""  class="layui-input">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
       <xblock>
          <span class="x-right" style="line-height:40px;font-weight:bold;float:left;">共有数据:{$count}条</span>
          <input type="number" value="" placeholder="输入游戏id,添加为代理人" id="gid"  class="layui-input"  style="width:200px;display:inline;margin-left:1000px;">
          <button class="layui-btn layui-btn-danger" onclick="mycfm()"><i class="layui-icon"></i>添加为代理</button>  
      </xblock>
      <table class="layui-table">
                  <thead>
                        <tr>
                            <th ><span style="display: inline-block; min-width: 60px;">代理人id</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">代理人昵称</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">代理人游戏ID</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">总金额</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">代理人级别</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">注册时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">最后一次登陆时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">操作时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">操作员</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">操作</span></th>
                        </tr>
                  </thead>
                  <tbody>
                         <volist name="lists" id="vo">
                                <tr>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[accountid]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">
                                        <a  onclick="openWin( {$vo['gameid']},'mycenter' )" style="color: #3f3f3f;" ><i class="fa fa-eye text-danger" style="font-size: 1.3em;"></i>       {$vo[nickname]}
                                        </a>
                                    </td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[gameid]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[allmoney]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #e10000;color: #a47900;">1级</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[regtime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[logouttime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[datetime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[operator]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;"><button type="button" onclick="deldl({$vo['accountid']})"  class="btn btn-primary">取消代理</button></td>
                                </tr>
                            </volist >
                   </tbody>
      </table>
      <div class="page">
            <ul id="example"></ul> 
            <input type="hidden" id="currentPage" value="{$p}">
            <input type="hidden" id="totalPages" value="{$totalPages}">
      </div>
    </div> -->
       <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页/添加代理</a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:39px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="{:U('member/agent')}" METHOD="GET">
          <div class="layui-input-inline">
                <select name="tradetype">
                    <option value="1" <?php  if($condi['tradetype']==1){echo "selected";} ?> >代理</option>
                    <option value="2" <?php  if($condi['tradetype']==2){echo "selected";} ?>>渠道</option>
                    <option value="3" <?php  if($condi['tradetype']==3){echo "selected";} ?>>推广</option>
                </select>
          </div>
          <input type="number" name="gameid"  placeholder="输入游戏id" value="{$condi['gameid']}"  class="layui-input">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
       <xblock>
          <span class="x-right" style="line-height:40px;font-weight:bold;float:left;">共有数据:{$count}条</span>
          <input type="number" value="" placeholder="输入游戏id,添加为代理人" id="gid"  class="layui-input"  style="width:200px;display:inline;margin-left:1000px;">
          <button class="layui-btn layui-btn-danger" onclick="mycfm()"><i class="layui-icon"></i>添加为代理</button>  
      </xblock>
      <table class="layui-table">
                  <thead>
                        <tr>
                            <th ><span style="display: inline-block; min-width: 60px;">ID</span></th>
                            <th ><span style="display: inline-block; min-width: 100px;">昵称</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">游戏ID</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">总金额</span></th>
                            <th ><span style="display: inline-block; min-width: 20px;">级别</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">注册时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">最后一次登陆时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">设置时间</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">操作员</span></th>
                            <th ><span style="display: inline-block; min-width: 60px;">操作</span></th>
                        </tr>
                  </thead>
                  <tbody>
                         <volist name="lists" id="vo">
                                <tr>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[accountid]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">
                                        <a  onclick="openWin( {$vo['gameid']},'mycenter' )" style="color: #3f3f3f;" ><i class="fa fa-eye text-danger" style="font-size: 1.3em;"></i>       {$vo[nickname]}
                                        </a>
                                    </td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[gameid]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[allmoney]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #e10000;color: #a47900;">1级</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[regtime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[logouttime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[datetime]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">{$vo[operator]}</td>
                                    <td class="contact-type text-dark" style="border-left: 1px solid #DDDDDD;color: #2b2b2b;">
                                        <button type="button" onclick="deldl({$vo['accountid']},{$condi['tradetype']})"  class="btn btn-primary">取消
                                            <if condition="$condi['tradetype'] eq 1">代理
                                              <elseif condition="$condi['tradetype'] eq 2"/>渠道
                                              <elseif condition="$condi['tradetype'] eq 3"/>推广
                                            </if> 
                                        </button></td>
                                </tr>
                            </volist >
                   </tbody>
      </table>
      <div class="page">
            <ul id="example"></ul> 
            <input type="hidden" id="currentPage" value="{$p}">
            <input type="hidden" id="totalPages" value="{$totalPages}">
      </div>
    </div>
    <script>
       function openWin(gameid,url) {
            layer.open({
              type: 2,
              title: '信息详情',
              shadeClose: true,
              shade: 0.8,
              maxmin: true,
              area: ['1400px', '90%'],
              content: '/member/'+url+'?id='+gameid //iframe的url
            }); 
        }
       //取消代理
        function deldl(accountid) {
            layer.confirm('您确定要取消该代理吗?', {
            btn : [ '确定', '取消' ]//按钮
            }, function(index) {
                 $.get("/member/deldl", {accountid:accountid},function (data) {
                          if(data.code =='success') {  
                            layer.msg('取消成功!',{icon:1,time:1000});
                            window.location.reload();
                          }else{  
                              layer.msg('取消失败!',{icon:2,time:4000});
                          }
                });
            });  
        }
        //取消代理
        function deldl(accountid,lx) {
            if(lx==1){ var s='代理'; }else if(lx==2){ var s='渠道'; }else if(lx==3){  var s='推广';} 
            layer.confirm('您确定要取消该'+s+'吗?', {
            btn : [ '确定', '取消' ]//按钮
            }, function(index) {
                 $.get("/member/deldl", {accountid:accountid,lx:lx},function (data) {
                          if  (data.code =='success') {  
                            layer.msg('取消成功!',{icon:1,time:3000});
                            window.location.reload();
                          }else{  
                              layer.msg('取消失败!',{icon:2,time:4000});
                          }
                });
            });  
        }
        //添加代理
        function mycfm(num) {
              layer.confirm('确定要添加此id的会员为代理人吗?', {
                btn : [ '确定', '取消' ]//按钮
              }, function(index) {
                  var accountid = $("#gid").val();
                  if(accountid == ''){
                      layer.msg('id不能为空!\n请指定添加人！！',{icon:2,time:3000});
                  }else {
                      $.get("/member/agentadd", {gameid:accountid},function (data) {
                            if  (data.code =='success') {  
                              layer.msg('添加成功!',{icon:1,time:1000});
                              window.location.reload();
                            }else{  
                                layer.msg(''+data.code+'!',{icon:2,time:4000});
                            }
                      });
                  }
              });  
        }
        
        //分页
        $(function(){
            var  currentPage= $("#currentPage").val();   
            var  totalPages= $("#totalPages").val();   
            var options = {
                    bootstrapMajorVersion:3, //对应的bootstrap版本
                    currentPage: currentPage, //当前页数，这里是用的EL表达式，获取从后台传过来的值
                    numberOfPages: 10, //每页页数
                    totalPages:totalPages, //总页数，这里是用的EL表达式，获取从后台传过来的值
                    shouldShowPage:true,//是否显示该按钮
                    itemTexts:function (type, page, current){     
                        switch (type) {
                            case "first":
                                return "首页";
                            case "prev":
                                return "上一页";
                            case "next":
                                return "下一页";
                            case "last":
                                return "末页";
                            case "page":
                                return page;
                        }
                    },
                    //点击事件
                    onPageClicked: function (event, originalEvent, type, page) {
                        var url='/member/agent.html'; 
                        var str = url+'?p='+page+'&'+ $( "form" ).serialize();
                        window.location.href = str;
                    }
            };
            $('#example').bootstrapPaginator(options);
        });
    </script>
  </body>
</html>